; Music of Heavy on the Magick (1986) (Gargoyle Games)
; Ripped by Megachur the 30/05/2009

; Need System Vectors !

	write "HEAVYOTM.BIN"

music_date_rip	equ &1e59
music_adr	equ &0ef9
first_theme	equ 0
last_theme	equ 0	; 0 -> 0

	read "music_header_v1_0.asm"


.l0ef9
	jp l0ef9
	db #f9,#0e,#be,#05
	dw #03bc,#0386,#0353,#0324
	dw #02f6,#02cc,#02a4,#027e
	dw #025a,#0238,#0218,#01fa
	dw #01de,#01c3,#01aa,#0192
	dw #017b,#0166,#0152,#013f
	dw #012d,#011c,#010c,#00fd
	dw #00ef,#00e1,#00d5,#00c9
	dw #00be,#00b3,#00a9,#009f
	dw #0096,#008e,#0086,#007f
	dw #0077,#0071,#006a,#0064
	dw #005f,#0059,#0054,#0050
	dw #004b,#0047,#0043,#003f
	dw #003c,#0038,#0035,#0032
	dw #002f,#0000
	db #ba,#03,#f8,#02,#80,#02,#e0,#01
	db #4d,#01,#38,#01,#b1,#00
.l0f7d equ $ + 3
.l0f7a
	db #7b,#ff,#00,#00
.l0f82 equ $ + 4
.l0f7e
	dw l0f7a,l1178,l0f7a,l1153
.l0f8a equ $ + 4
.l0f86
	dw l0f7a,l119d,l0f7a,l11c2
.l0f92 equ $ + 4
.l0f90 equ $ + 2
.l0f8e
	db #00,#00,#00,#00,#00,#00,#00,#38
.l0f9d equ $ + 7
.l0f9c equ $ + 6
.l0f96
	db #05,#0f,#05,#00,#00,#00,#00,#f5
.l0fa1 equ $ + 3
.l0f9e
	db #04,#05,#06,#0e,#0e,#0e,#0d,#0d
	db #0d,#0d,#0c,#0c,#0c,#0c,#0b,#0b
	db #0b,#0b,#0b,#0b,#0b,#0b,#0a,#0a
	db #0a,#0a,#0a,#09,#09,#09,#08,#08
	db #07,#07,#06,#0c,#0d,#0d,#0c,#0c
	db #0c,#0c,#0c,#0b,#0c,#0c,#0c,#0d
	db #0d,#0c,#0c,#07,#09,#0b,#0c,#0d
	db #0f,#0e,#0e,#0d,#0c,#0b,#09,#08
	db #07,#06,#05,#0c,#0c,#0c,#0c,#0c
	db #0c,#0c,#0c,#0c,#0c,#0c,#0c,#0c
	db #0c,#0c,#0c
.l0ff1
	dw l0f7a,l1178,l0f7a,l1153
	dw l0f7a,l119d,l0f7a,l11c2
	dw #01e1,#0205
;
.real_init_music
;
	ld hl,l0ff1
	ld de,l0f7e
	ld bc,#0010
	ldir
	ld de,l0f9d
	ld c,#04
	ldir
	xor a
	ld (l0f7d),a
	ret
;
.play_music
;
	di
	xor a
	ld hl,l0f9c
	ld (hl),a
	ld hl,l0f7e
	call l1070
	ld hl,l0f8e
	ld (hl),d
	inc l
	ld (hl),e
	ld hl,l0f82
	call l1070
	ld hl,l0f90
	ld (hl),d
	inc l
	ld (hl),e
	ld hl,l0f86
	call l1070
	ld hl,l0f92
	ld (hl),d
	inc l
	ld (hl),e
	ld hl,l0f8a
	call l1070
	call l10cb
	ld d,#00
	ld b,#08
	call l1107
	call l10a6
	ld a,(l0f7d)
	inc a
	cp #08
	jr nz,l1062
	xor a
.l1062
	ld (l0f7d),a
	ei
	ret
;
.stop_music
;
	ld d,#07
	ld e,#3f
	call l10e6
	ei
	ret
.l1070
	ld e,(hl)
	inc l
	ld d,(hl)
	ld a,(l0f7d)
	cp #00
	jr nz,l107b
	inc de
.l107b
	ld a,(de)
	cp #ff
	jr z,l109e
	ld (hl),d
	dec l
	ld (hl),e
	add a
	ld e,a
	ld d,#00
	ld hl,l11e7
	add hl,de
	add hl,de
	add hl,de
	add hl,de
	ld a,(l0f7d)
	ld e,a
	add hl,de
	ld a,(hl)
	ld b,a
	add a
	ld hl,l0f8e
	ld l,a
	ld d,(hl)
	inc l
	ld e,(hl)
	ret
.l109e
	inc l
	ld e,(hl)
	inc l
	ld d,(hl)
	dec l
	dec l
	jr l107b
.l10a6
	ld a,#01
	call l1115
	ld a,#02
	call l1115
	ld a,#03
	call l1115
	ld a,(l0f9d)
.l10b8
	ld b,#46
.l10ba
	nop
	djnz l10ba
	inc a
	jr nz,l10b8
	ld hl,l0f9c
	inc (hl)
	ld a,(hl)
	cp #10
	ret z
	jp l10a6
.l10cb
	ld a,b
	cp #00
	ret z
	bit 2,b
	ret z
	and #03
	ld c,a
	ld a,#e0
	and b
	rlca
	rlca
	rlca
	ld b,a
	ld d,#00
	ld e,c
	ld hl,l0f9e
	add hl,de
	dec hl
	ld (hl),b
	ret
.l10e6
	push bc
	ld b,#f4
	out (c),d
	ld b,#f6
	in a,(c)
	or #c0
	out (c),a
	and #3f
	out (c),a
	ld b,#f4
	out (c),e
	ld b,#f6
	ld c,a
	or #80
	out (c),a
	out (c),c
	pop bc
	inc d
	ret
.l1107
	ld hl,l0f8e
	ld a,d
	add l
	ld l,a
.l110d
	ld e,(hl)
	inc hl
	call l10e6
	djnz l110d
	ret
.l1115
	ld hl,l0f8e
	ld c,a
	dec l
	add l
	add c
	ld l,a
	ld a,(hl)
	dec l
	or (hl)
	ret z
	ld l,#95
	ld a,c
	add l
	ld l,a
	ex de,hl
	ld hl,#0008
	add hl,de
	ld a,(hl)
	cp #00
	ret z
	ld hl,l0fa1
	dec a
	add a
	add a
	add a
	add a
	ld d,#00
	ld e,a
	add hl,de
	ld a,(l0f9c)
	ld e,a
	add hl,de
	ld b,(hl)
	ld hl,l0f96
	ld e,c
	add hl,de
	dec l
	ld a,(hl)
	cp b
	ret z
	ld (hl),b
	ld e,b
	ld a,#07
	add c
	ld d,a
	jp l10e6
.l1153
	db #02,#02,#02,#02,#03,#04,#05,#06
	db #07,#08,#09,#0a,#0b,#0c,#0d,#0e
	db #0f,#10,#0f,#11,#12,#13,#02,#02
	db #14,#15,#16,#17,#18,#19,#1a,#1b
.l1178 equ $ + 5
	db #1c,#1d,#02,#1e,#ff,#1f,#20,#1f
	db #20,#1f,#20,#1f,#20,#1f,#20,#1f
	db #20,#1f,#20,#1f,#21,#22,#23,#22
	db #24,#1f,#20,#1f,#25,#26,#27,#28
	db #29,#2a,#2a,#2a,#2b,#2c,#2c,#2d
.l119d equ $ + 2
	db #2e,#ff,#2f,#30,#2f,#30,#2f,#30
	db #2f,#30,#2f,#30,#2f,#30,#2f,#30
	db #2f,#30,#31,#32,#31,#32,#2f,#30
	db #2f,#30,#02,#02,#02,#02,#33,#33
.l11c2 equ $ + 7
	db #34,#34,#31,#31,#2f,#2f,#ff,#35
	db #01,#01,#01,#01,#01,#01,#01,#01
	db #01,#01,#01,#01,#01,#01,#01,#01
	db #01,#01,#01,#01,#01,#01,#36,#01
	db #01,#01,#37,#01,#01,#01,#01,#38
.l11e7 equ $ + 4
	db #38,#01,#39,#ff,#00,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#00,#35,#35,#35,#35
	db #35,#35,#35,#35,#0c,#0c,#0c,#0c
	db #18,#18,#18,#18,#1a,#1a,#1a,#1a
	db #18,#18,#0c,#0c,#16,#16,#16,#16
	db #18,#18,#18,#18,#16,#16,#16,#16
	db #0a,#0a,#16,#16,#14,#14,#14,#14
	db #08,#08,#08,#08,#08,#08,#08,#08
	db #08,#0a,#0c,#0f,#0e,#0e,#0e,#0e
	db #11,#11,#11,#11,#13,#13,#13,#13
	db #0e,#0e,#0e,#0e,#0c,#0c,#18,#0c
	db #0c,#0c,#18,#0c,#0c,#0c,#18,#0c
	db #0c,#0c,#18,#1a,#1b,#1a,#1b,#1a
	db #1b,#1a,#18,#1a,#1b,#1a,#1b,#1a
	db #1d,#1d,#1d,#1d,#1d,#1d,#1d,#1d
	db #1d,#1f,#20,#1d,#22,#20,#1f,#20
	db #22,#20,#1f,#20,#22,#20,#1f,#1d
	db #1b,#19,#1b,#19,#18,#18,#18,#18
	db #0c,#0c,#0c,#0c,#18,#18,#18,#18
	db #18,#18,#18,#18,#30,#2b,#24,#1f
	db #30,#2b,#24,#1f,#30,#29,#24,#1d
	db #30,#29,#24,#1d,#2e,#29,#26,#22
	db #2e,#29,#26,#22,#2d,#29,#24,#1f
	db #1d,#1f,#21,#24,#00,#00,#01,#01
	db #02,#02,#03,#03,#04,#04,#05,#05
	db #06,#06,#07,#07,#08,#08,#09,#09
	db #0a,#0a,#0b,#0b,#0c,#0c,#0d,#0d
	db #0e,#0e,#0f,#0f,#10,#11,#12,#13
	db #14,#15,#16,#17,#18,#19,#1a,#1b
	db #1c,#1d,#1e,#1f,#1f,#22,#27,#2b
	db #30,#32,#28,#30,#26,#24,#27,#24
	db #29,#24,#2b,#24,#2c,#24,#2b,#24
	db #27,#24,#2b,#24,#2c,#24,#2b,#24
	db #27,#24,#2b,#29,#2b,#29,#2c,#29
	db #2e,#29,#30,#29,#31,#29,#30,#29
	db #2c,#29,#30,#29,#31,#29,#30,#29
	db #2c,#29,#30,#24,#2c,#24,#2b,#24
	db #27,#24,#2b,#35,#18,#1a,#18,#1a
	db #1b,#1a,#18,#1a,#0c,#0e,#0c,#0e
	db #0f,#0e,#0c,#0e,#16,#18,#16,#18
	db #1a,#18,#16,#1a,#18,#16,#18,#16
	db #18,#16,#15,#11,#0c,#0f,#0c,#10
	db #0c,#11,#0c,#12,#0c,#0f,#0c,#10
	db #18,#17,#16,#15,#11,#13,#14,#11
	db #1a,#1a,#18,#18,#1f,#1d,#1f,#1d
	db #1f,#1d,#1b,#1a,#18,#1b,#1f,#24
	db #27,#2b,#30,#33,#24,#26,#24,#27
	db #24,#29,#24,#2b,#24,#2c,#24,#2b
	db #24,#27,#24,#2b,#29,#2b,#29,#2c
	db #29,#2e,#29,#30,#29,#31,#29,#30
	db #29,#2c,#29,#30,#30,#24,#30,#24
	db #30,#24,#30,#24,#30,#2b,#24,#2b
	db #30,#2b,#24,#2b,#2d,#00,#00,#00
	db #00,#00,#00,#00,#00,#00,#00,#00
	db #00,#00,#00,#8d,#00,#00,#00,#00
	db #00,#00,#00,#6f,#2a,#2a,#2a,#2a
	db #2a,#2a,#2a,#2a,#00,#00,#00,#00
	db #00,#00,#00,#4f,#58,#78,#83,#04
	db #bd,#17,#00,#00
;
.init_music	; added  by Megachur
;
;#a113	; init music env/ent
;
.init_music_envent
;
	ld a,#02
	ld hl,la0ad
	call #bcbc
	ld a,#01
	ld hl,la0a9
	call #bcbf
	ld a,#02
	ld hl,la0ad
	call #bcbf
;	ret
	jp real_init_music
.la0ad equ $ +4
.la0a9
	db #01,#64,#10,#01,#01,#64,#ff,#02
	db #00,#14,#15,#18,#02
; #af3a
;ld hl,#fb5e
;.laf3d
;call #bb09
;jr c,laf3d
;call #1005	; init music
;.laf45
;call #101c	; play music
;halt
;call #bb09
;jr nc,laf45
;call #1067
;ret
;jp #706d


;
.game_name
	db "Heavy on the Magick",0
.game_year
	db "1986",0
.game_publisher
	db "Gargoyle Games",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
